/*
 * Author: 胡皇
 * Date: 2021-01-29 23:08:36
 * LastEditors: 胡皇
 * LastEditTime: 2021-03-28 14:52:46
 * Description: 
 */
// pages/orderdetails/orderdetails.js
const app = getApp();
const $api = require('../../../service/api').API;
Page({

    /**
     * 页面的初始数据
     */
    data: {

        imgUrl: app.globalData.imgUrl,
        list: [],
        information: [{}],
        str_orderid: 0

    },
    enlarge(e){
        let url=e.detail.value;
        wx.previewImage({
            current: url, // 当前显示图片的http链接
            urls: [] // 需要预览的图片http链接列表
          })

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        var str_orderid = options.str_orderid;
        let that = this;
        that.setData({
            str_orderid: str_orderid
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        let that = this;
        $api.getAllorder(wx.getStorageSync('openid')).then((res) => {
            console.log(res);
            wx.showToast({
				title: res.message,
				icon: 'success',
				duration: 2000
			});
            var list = [];
            for (let i = 0; i < res.data.length; i++) {
                if (res.data[i].str_orderid == that.data.str_orderid) {
                    list.push(res.data[i]);
                    if (list.style == 1) {
                        list[0].style = "上门预约";
                    } else {
                        list[0].style = "到店预约";
                    }
                }
            }
            that.setData({
                list: list
            });
            console.log(that.data.list);
        })
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    }
})